CREATE TABLE [dbo].[LicenseMain]
(
[LicenseMasterKey] [uniqueidentifier] NOT NULL,
[LicenseKey] [uniqueidentifier] NOT NULL,
[OrganizationKey] [uniqueidentifier] NOT NULL,
[NamedLicenseCount] [int] NOT NULL CONSTRAINT [DF_LicenseMain_NamedLicenseCount] DEFAULT ((0)),
[UnnamedLicenseCount] [int] NOT NULL CONSTRAINT [DF_LicenseMain_UnnamedLicenseCount] DEFAULT ((0)),
[EffectiveDate] [datetime] NOT NULL,
[ExpirationDate] [datetime] NULL,
[Checksum] [nvarchar] (250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL CONSTRAINT [DF_LicenseMain_Checksum] DEFAULT ((0)),
[MarkedForDeleteOn] [datetime] NULL
) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LicenseMain] ADD CONSTRAINT [PK_LicenseMain] PRIMARY KEY CLUSTERED ([LicenseMasterKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LicenseMain_LicenseKey] ON [dbo].[LicenseMain] ([LicenseKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_LicenseMain_OrganizationKey] ON [dbo].[LicenseMain] ([OrganizationKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[LicenseMain] ADD CONSTRAINT [FK_LicenseMain_License] FOREIGN KEY ([LicenseKey]) REFERENCES [dbo].[License] ([LicenseKey])
GO
ALTER TABLE [dbo].[LicenseMain] ADD CONSTRAINT [FK_LicenseMain_LicenseMaster] FOREIGN KEY ([LicenseMasterKey]) REFERENCES [dbo].[LicenseMaster] ([LicenseMasterKey])
GO
ALTER TABLE [dbo].[LicenseMain] ADD CONSTRAINT [FK_LicenseMain_OrganizationMain] FOREIGN KEY ([OrganizationKey]) REFERENCES [dbo].[OrganizationMain] ([OrganizationKey])
GO